package com.cskaoyan.javase.oop1._7exercise.pvz;

import java.io.PushbackInputStream;

/**
 * 植物类
 *
 * @since 11:22
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Plant {
    // 属性
    String name;
    double price;
    int hp;
    int damage;

    // 程序的功能实现,是由对象之间的交互来完成的,为了方便对象之间的交互,普通采取的方式是,持有对方对象的引用,作为自身的成员变量
    Zombie plantZ;

    public Plant(String name, double price, int hp, int damage) {
        this.name = name;
        this.price = price;
        this.hp = hp;
        this.damage = damage;
    }

    // 行为

    public void planting() {
        System.out.println("以" + price + "☀的价格,种植了" + name);
    }

    public void attack() {
        System.out.println(name + "正在攻击" + plantZ.name);
    }

    public void beAttacked() {
        System.out.println(name + "正在被" + plantZ.name + "攻击,还剩下" + (hp - plantZ.damage));
    }

}
